package com.mdb.open.trade.service.trade;


/*
* Copyright (C), 2017-2019 澳发科技(MDB)
* FileName: TfLoanApplyItemInfoService.java
* Author:   you.yichao
* Date:     2019-10-11
* History:
* <author>          <time>          <version>          <desc>
* you.yichao         2019-10-11          V1.00             代码生成器初始生成代码
* -----------------------------------------------------------
* 作者姓名           修改时间           版本号            描述
*/


import com.baomidou.dynamic.datasource.annotation.DS;
import com.mdb.bc.api.data.ResultEx;
import com.mdb.bc.database.mybatisplus.SuperService;
import com.mdb.open.trade.common.MdbDataSource;
import com.mdb.open.trade.domain.bo.trade.LoanApplyItemInfoBo;
import com.mdb.open.trade.domain.po.trade.LoanApplyItemInfo;
import com.mdb.open.trade.mapper.trade.TfLoanApplyItemInfoMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类描述：
 *  贸易融资申请商品信息表 服务类
 *
 * @author you.yichao
 * @date 2019-10-11
 */
@Service
@DS(MdbDataSource.TRADE)
public class TfLoanApplyItemInfoService extends SuperService<TfLoanApplyItemInfoMapper, LoanApplyItemInfo> {

    public ResultEx saveItemInfo(List<LoanApplyItemInfoBo> loanApplyItemInfoBoList) {

        for(LoanApplyItemInfoBo i : loanApplyItemInfoBoList){
            LoanApplyItemInfo info = new LoanApplyItemInfo();
            info.setApplyOrderNo(i.getApplyOrderNo());
            info.setApplyOrderItemNo(i.getItemNo());
            info.setApplyOrderCustomsNo(i.getApplyOrderCustomsNo());
            info.setCustomsNo(i.getCustomsNo());
            info.setCustomerCode(i.getCustomerCode());
            info.setMcustomerCode(i.getMcustomerCode());
            info.setCustomerName(i.getCustomerName());
            info.setMerchantNo(i.getMerchantNo());
            info.setMerchantName(i.getMerchantName());
            info.setBusinessNo(i.getBusinessNo());
            info.setItemCnName(i.getItemCnName());
            info.setItemEnName(i.getItemEnName());
            info.setHsCode(i.getHsCode());
            info.setBrand(i.getBrand());
            info.setUnit(i.getUnit());
            info.setQuantity(i.getQuantity());
            info.setContractAmount(i.getContractAmount());
            info.setContractCcy(i.getContractCcy());
            info.setCustomUnitAmount(i.getCustomUnitAmount());
            info.setCustomUnitCcy(i.getCustomUnitCcy());
            info.setCustomTotalAmount(i.getCustomTotalAmount());
            info.setCustomTotalCcy(i.getCustomTotalCcy());
            info.setStatus(i.getStatus());
            info.setSourceType(i.getSourceType());

            int count = this.baseMapper.insert(info);
            if (count != 1) {
                return ResultEx.fail();
            }
        }

        return ResultEx.ok();
    }

}
